﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace App_Utils
{
    public class clsConstants
    {
        #region Constants
        public const string DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss";
        public const string CREATE_USER = "create_user";
        public const string CREATE_DATE = "create_date";
        public const string MODIFY_USER = "modify_user";
        public const string MODIFIED_DATE = "modified_date";
        public const string START_INDEX = "start";
        public const string MAX_RECORD = "maxrecord";

        public const string SESSION_USER = "USERTABLE";
        public const string SESSION_USER_ALL = "SESSION_USER_ALL";
        public const string SESSION_USERID = "USERID";

        public const string Uploads = "Uploads";
        public const string UserImages = "UserImages";
        public const string logs = "logs";
        public const string backuplogs = "backuplogs";

        public const string OK = "OK";
        public const string ERROR = "ERROR";
        #endregion

        
        #region Enums
        public enum AccessFunctions
        {
            JobOrderCreation = 0
        }

        

        public enum ResponseCodes
        {
            response_OK = 0,
            response_error = 1,
            response_fail = 2
        }

        public enum CountryCodes
        {
            countryCanada = 0
        }

        public enum PageAction
        {
            pageAction_browse = 0,
            pageAction_modify = 1,
            pageAction_delete = 2
        }

        public enum Language
        {
            langEnglish = 0,
            langFrench = 1,
            langSpanish = 2
        }

        public enum Keytypes
        {
            dbPrimary = 1,
            dbUnique = 2,
            dbRegularWithUpdate = 3,
            dbRegularNoUpdate = 4,
            dbPrimaryWithUpdate = 5
        };

        public enum Datatypes
        {
            dbNumber = 1,
            dbString = 2,
            dbInt = 3,
            dbInt16 = 4,
            dbByte = 5,
            dbDateTime = 6,
            dbBool = 7,
            dbFloat = 8,
            dbStringNoTrim = 9,
            dbEncryptedString = 10,
            dbEncryptedStringNoTrim = 11,
            dbTime = 12,
            dbDate = 13,
            dbDropDown = 14,
            dbDouble = 15,
            dbHidden = 16,
            dbFile = 17
        };

        public enum AccessLevel
        {
            browse_level = 5,
            update_level = 8,
            delete_level = 10
        };

        public enum UserGroupValue
        {
            [StringValue("Client Admin")]
            group_name = 1,
            [StringValue("Default Group For Admin")]
            group_description = 2,
        }

        public enum AppicationDateFormat
        {
            [StringValue("{0:MM/dd/yyyy}")]
            MMddyyyy = 1
        }

        public enum module
        {
            [StringValue("SuperAdmin")]
            SuperAdmin = 1, 
            [StringValue("User")]
            User = 2,
            [StringValue("Student")]
            Student = 3            
        }

        public enum Info_Type
        {
            [StringValue("Email")]
            Email = 1,            
            [StringValue("Phone")]
            Phone = 2
        }


        public class StringValue : System.Attribute
        {
            private string _value;

            public StringValue(string value)
            {
                _value = value;
            }

            public string Value
            {
                get { return _value; }
            }

            public static string GetStringValue(Enum value)
            {
                string output = null;
                Type type = value.GetType();

                //Check first in our cached results...

                //Look for our 'StringValueAttribute' 

                //in the field's custom attributes

                System.Reflection.FieldInfo fi = type.GetField(value.ToString());
                StringValue[] attrs =
                   fi.GetCustomAttributes(typeof(StringValue),
                                           false) as StringValue[];
                if (attrs.Length > 0)
                {
                    output = attrs[0].Value;
                }

                return output;
            }
        } 
        #endregion
    }
}
